package gxmzu.gxmzuproject.controller;

import gxmzu.gxmzuproject.service.MiniGroupChatService;
import gxmzu.gxmzuproject.param.MiniGroupChatQueryParam;
import gxmzu.gxmzuproject.vo.MiniGroupChatQueryVo;
import gxmzu.gxmzuproject.entity.MiniGroupChat;
import gxmzu.gxmzuproject.config.common.BaseController;
import gxmzu.gxmzuproject.config.common.ApiResult;
import gxmzu.gxmzuproject.config.common.Paging;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Code534
 * @since 2022-08-11
 */
@Slf4j
@RestController
@RequestMapping("/miniGroupChat")
@Api(value = "小程序-拼车-群聊-模块", tags = {"小程序-拼车-群聊-模块"})
public class MiniGroupChatController extends BaseController {

    @Autowired
    private MiniGroupChatService miniGroupChatService;

    /**
    * 添加
    */
    @PostMapping("/add")
    @ApiOperation(value = "添加MiniGroupChat对象",notes = "添加")
    public ApiResult<Boolean> addMiniGroupChat(@Valid @RequestBody MiniGroupChat miniGroupChat) {
        boolean flag = miniGroupChatService.save(miniGroupChat);
        return ApiResult.result(flag);
    }

    /**
    * 修改
    */
    @PutMapping("/update")
    @ApiOperation(value = "修改MiniGroupChat对象",notes = "修改")
    public ApiResult<Boolean> updateMiniGroupChat(@Valid @RequestBody MiniGroupChat miniGroupChat) {
        boolean flag = miniGroupChatService.updateById(miniGroupChat);
        return ApiResult.result(flag);
    }

    /**
    * 删除
    */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除MiniGroupChat对象",notes = "删除")
    public ApiResult<Boolean> deleteMiniGroupChat(@PathVariable String id) {
        boolean flag = miniGroupChatService.removeById(id);
        return ApiResult.result(flag);
    }

    /**
    * 获取
    */
    @GetMapping("/info/{id}")
    @ApiOperation(value = "获取MiniGroupChat对象详情",notes = "查看")
    public ApiResult<MiniGroupChatQueryVo> getMiniGroupChat(@PathVariable String id) {
        MiniGroupChatQueryVo miniGroupChatQueryVo = miniGroupChatService.getMiniGroupChatById(id);
        return ApiResult.ok(miniGroupChatQueryVo);
    }

    /**
     * 分页列表
     */
    @PostMapping("/getPageList")
    @ApiOperation(value = "获取MiniGroupChat分页列表",notes = "分页列表")
    public ApiResult<Paging<MiniGroupChatQueryVo>> getMiniGroupChatPageList(@Valid @RequestBody(required = false) MiniGroupChatQueryParam miniGroupChatQueryParam) {
        Paging<MiniGroupChatQueryVo> paging = miniGroupChatService.getMiniGroupChatPageList(miniGroupChatQueryParam);
        return ApiResult.ok(paging);
    }

}

